<template>
  <div class="extrainfo">
    <div class="today">
      {{now}}
    </div>
    <div class="extra">
      <div class="extraitem">
        <p>累计绑定推荐码<span class="itemnum">{{$store.state.user.totalSpreadCount}}</span>人</p>
      </div>
      <div class="extraitem">
        <p>当前亲友群<span class="itemnum">{{$store.state.user.totalFriendsCount}}</span>人</p>
      </div>
      <div class="extraitem">
        <p>今日新增<span class="itemnum">{{$store.state.user.currSpreadCount}}</span>人</p>
      </div>
      <div class="extraitem">
        <p>今日新增<span class="itemnum">{{$store.state.user.currFriendsCount}}</span>人</p>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    name: "extrainfo",
    data() {
      return {
        a: 1,
        now: 0
      };
    },
    methods: {
      formateDate: function(date) {
        if (date == "" || date == "undefined") {
          return "";
        }
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? "0" + m : m;
        var d = date.getDate();
        d = d < 10 ? "0" + d : d;
        var h = date.getHours();
        h = h < 10 ? "0" + h : h;
        var minute = date.getMinutes();
        minute = minute < 10 ? "0" + minute : minute;
        var seconds = date.getSeconds();
        seconds = seconds < 10 ? "0" + seconds : seconds;
        return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + seconds;
      }
    },
    mounted() {
      let that = this;
      let time = new Date();
      this.now = this.formateDate(time);
      setInterval(function() {
        let time = new Date();
        that.now = that.formateDate(time);
      }, 1000);
    }
  };
</script>

<style lang="scss" scoped>
  .extrainfo {
    padding: 10px 10px;
    .today {
      border-left: 10px solid #ffba00;
      padding: 5px;
      font-size: 16px;
      color: #441900;
    }
    .extra {
      display: block;
      font-size: 0;
      position: relative;
      padding: 5px 0;
      border-bottom: 1px solid #ece6d6;
      &:before {
        content: "";
        display: block;
        background: #ece6d6;
        top: 10%;
        left: 50%;
        width: 1px;
        height: 80%;
        position: absolute;
      }
      .extraitem {
        //padding: 5px 10px;
        width: 50%;
        padding: 5px 0 5px 20px;
        font-size: 14px;
        color: #441900;
        display: inline-block;
        text-align: left;
        line-height: 1;
        p {
          //background: #fbf8f8;
          //padding: 10px;
          //border: 1px solid #ffba00;
          border-radius: 2px;
          .itemnum {
            color: #d95000;
          }
        }
      }
    }
  }
</style>

